package com.weiweiqin.service.impl;

import com.weiweiqin.dao.UserMobileSourceDao;
import com.weiweiqin.model.UserMobileSource;
import com.weiweiqin.service.UserMobileSourceService;
import com.weiweiqin.vo.common.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserMobileSourceServiceImpl implements UserMobileSourceService {
	@Autowired
	private UserMobileSourceDao userMobileSourceDao;

	public void update(UserMobileSource userMobileSource) {
		userMobileSourceDao.update(userMobileSource);

	}

	public UserMobileSource getByMobile(String mobile) {
		return userMobileSourceDao.getByMobile(mobile);
	}


	public void save(UserMobileSource userMobileSource) {
		UserMobileSource byMobile = userMobileSourceDao.getByMobile(userMobileSource.getMobile());
		//防止重复手机号插入
		if(null == byMobile) {
			userMobileSourceDao.insert(userMobileSource);
		}else {
			System.out.println("重复号码="+userMobileSource.getMobile());
		}

	}

	public List<UserMobileSource> pageList(Page page,Map<String,Object> conditions) {
		return userMobileSourceDao.pageList(page,conditions);
	}

	public int totalCount(Map<String, Object> conditions) {
		return userMobileSourceDao.totalCount(conditions);
	}

	public void del(int id) {
		userMobileSourceDao.delete(id);
	}

	public UserMobileSource get(int id) {
		return userMobileSourceDao.get(id);
	}

}